package com.edgardeng;

import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;

public class ConnectionUtil {

    public final static String QUEUE_NAME_HELLO_WORLD = "test_hello_world";
    public final static String QUEUE_NAME_WORK_QUEUE = "test_work_queue";

    public final static String HOST_LOCAL = "192.168.1.100";

    public final static String EXCHANGE_NAME = "test_exchange";
    public final static String EXCHANGE_NAME_DIRECT = "test_exchange_direct";
    public final static String EXCHANGE_NAME_TOPIC = "test_exchange_topic";

    public final static String EXCHANGE_TYPE_FANOUT = "fanout";
    public final static String EXCHANGE_TYPE_DIRECT = "direct";
    public final static String EXCHANGE_TYPE_TOPIC = "topic";

    public final static String ROUTER_KEY_DIRECT_ONE = "direct_one";
    public final static String ROUTER_KEY_DIRECT_TWO = "direct_two";
    public final static String ROUTER_KEY_DIRECT_THREE = "direct_three";


    public static Connection getConnection () throws Exception {
        try {
            ConnectionFactory factory = new ConnectionFactory();
            factory.setHost(HOST_LOCAL); // 设置rabbitmq server
            factory.setPort(5672);
            factory.setUsername("test");
            factory.setPassword("123456");
            factory.setVirtualHost("test");
            return factory.newConnection();
        } catch (Exception e) {
            e.printStackTrace();
            throw e;
        }

    }
}
